<template>
  <div>
    <h4>{{ photoinfoList.title}}</h4>
    <p class="formot">
      <span>发表时间:{{ photoinfoList.add_time | dateFormat}}</span>
      <span>点击{{ photoinfoList.click}}次</span>
    </p>
    <hr />
    <!-- 缩略图模块 -->
    <div class="tumblist">
      <vue-preview :slides="list"></vue-preview>
    </div>
    <!-- 内容区域 -->
    <div class="contenter" v-html="photoinfoList.content"></div>
    <!-- 放置一个已将写过的评论子组件 -->
    <cmt-box :id="id"></cmt-box>
  </div>
</template>
<script>
import comment from "../componentssub/commet.vue";
export default {
  data() {
    return {
      id: this.$route.params.id,
      photoinfoList: [],
      list: [
        {
          src: " ",
          msrc: " ",
          alt: " picture1 ",
          title: "Image.Caption 1",
          w: 600,
          h: 400
        }
      ]
    };
  },
  created() {
    this.getThumbs();
    this.getphotoInfo();
  },
  methods: {
    // 获取缩略图模块
    getThumbs() {
      this.$http.get("api/getthumimages/" + this.id).then(result => {
        // console.log(result);
        if (result.data.status === 0) {
          this.list = result.data.message.map((item, index) => {
            return {
              src: item.src,
              msrc: item.src,
              alt: `picture ${index}`,
              title: `Image.Caption ${index}`,
              w: 600,
              h: 400
            };
          });
        }
      });
    },
    // 获取详情页
    getphotoInfo() {
      this.$http.get("api/getimageInfo/" + this.id).then(result => {
        // console.log(result);
        this.photoinfoList = result.data.message[0];
      });
    }
  },
  components: {
    "cmt-box": comment
  }
};
</script>
<style lang="scss" scope>
h4 {
  color: skyblue;
  font-size: 16px;
}
.formot {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: springgreen;
}
.contenter {
  font-size: 14px;
  color: cornflowerblue;
}
.tumblist {
  /deep/ .my-gallery {
    display: flex;
    flex-wrap: wrap;
    figure {
      width: 30%;
      margin: 5px;
      img {
        width: 100%;
      }
    }
  }
}
</style>
